<?php
/* 
* [***********************]
* @author: mazhenyu[houdunwangmzy@163.com]
* @Date:   2014-07-01 21:00:04
* @Last Modified time: 2014-07-04 19:39:09
*/
class ComInfoControl extends PublicControl{
	public function baseinfo(){
		$ComInfoModel = K('ComInfo');
		//如果基本信息存在，则取修改基本信息，如果不存在则添加
		if($ComInfoModel->have_info()) go(U('edit_baseinfo'));

		if(IS_POST){
			if(!$ComInfoModel->create()) $this->error($ComInfoModel->error);

			$ComInfoModel->add_data();
		
			$this->success('保存成功');
		}
		
		$topCity = K('City')->topCity;
		$this->assign('topCity', $topCity);
		
		$this->display();
	}

		/**
	 * [edit_baseinfo 修改企业基本信息资料]
	 * @return [type] [description]
	 */
	public function edit_baseinfo(){
		$comModel = K('ComInfo');
		if(IS_POST){
			// 执行验证如果验证通过执行修改
			if(!$comModel->create()) $this->error($comModel->error);
			//执行ComInfo里面的修改
			$comModel->update_data();
			//成功提示
			$this->success('保存成功');
		}
		//获得旧信息
		$data = $comModel->get_info(session('uid'));
		//实例化城市模型
		$cityModel = K('City');
		// p($data);

		//处理两个城市id分别压入到以前数组$data里面，然后反出
		// $data = $cityModel->get_old_city($data, 'city_cityid');
		$cityModel = K('City');
		$city = $cityModel->get_city($data['city_cityid']);
		$this->assign('data', $data);
		//根据$data里面的1级城市id 调用2级城市数据
		// $sonCity = $cityModel->get_son_city($data['fir_city']);
		$this->assign('city', $city);

		//调用顶级城市
		$topCity = $cityModel->topCity;
		$this->assign('topCity', $topCity);
		$this->display();
	}


	public function character()
	{
		$model = K('ComOtherInfo');
		if (IS_POST) {
			if(!$model->add_character_data())$this->error($model->error);
			$this->success('上传成功',U('Index/index'));
		}
		$this->display();
	}


	public function logo()
	{
		$model = K('ComOtherInfo');
		if (IS_POST) {
			if(!$model->update_logo())$this->error($model->error,U('character'));
			$this->success('上传成功',U('Index/index'));
		}
		$this->display();
	}
}
?>
